import os
import sys
import re

# fileinfo
def info(object, spacing=10, collapse=1):      
    """Print methods and doc strings.
    Takes module, class, list, dictionary, or string."""
    methodList = [method for method in dir(object) if callable(getattr(object, method))]
    processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)
    print "\n".join(["%s %s" % (method.ljust(spacing), processFunc(str(getattr(object, method).__doc__))) for method in methodList])


roman_num_pattern = """
    ^                   # beginning of string
    (M{0,4})              # thousands - 0 to 4 M's
    (CM|CD|D?C{0,3})    # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),
                        #            or 500-800 (D, followed by 0 to 3 C's)
    (XC|XL|L?X{0,3})    # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),
                        #        or 50-80 (L, followed by 0 to 3 X's)
    (IX|IV|V?I{0,3})    # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),
                        #        or 5-8 (V, followed by 0 to 3 I's)
    $                   # end of string
    """


if __name__ == "__main__":
    print re.search(roman_num_pattern, 'MMMMDCCCLXXXVIII', re.VERBOSE).groups()
    phonePattern = re.compile(r'^(\d{3})-(\d{3})-(\d{4})$') 
    print phonePattern.search('800-555-1212').groups()
